package mango.server;

 

public class Vulture extends Thread {
	protected MangoServer server;
	
	protected Vulture (MangoServer mango) {
		super(mango.threadGroup, "Connection Vulture");
		server = mango;
		this.start();
	}
	
	public synchronized void run() {
		for (;;) {
			try {this.wait(5000);}
			catch (InterruptedException e) {};
			
			synchronized(server.connections) {
				// Loop through all the connections
				for (int i=0; i < server.connections.size(); i++) {
					Connection c = (Connection)server.connections.elementAt(i);
					
					if (! c.isAlive()) {
						server.connections.removeElementAt(i);
						server.connectionList.remove(i);
						i--;
					}
				}
			}
			
		}
	}

}
